package org.chen;

import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.PostConstruct;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.Date;
import java.util.TimeZone;

@Slf4j
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, SpringBootConfiguration.class}) //去掉数据源
@EnableDiscoveryClient
@EnableAsync //开启异步调用
@EnableTransactionManagement
@MapperScan("org.chen.mapper")
public class OrderApplication {
    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class,args);
    }

    @PostConstruct
    public void checkTimeZone() {
        TimeZone currentTimeZone = TimeZone.getDefault();
        log.info("Current TimeZone: {} ({})", currentTimeZone.getID(),
                currentTimeZone.getDisplayName());

        // 验证日期处理
        Date now = new Date();
        LocalDateTime localDateTime = LocalDateTime.now();
        ZonedDateTime zonedDateTime = ZonedDateTime.now();

        log.info("Current Date: {}", now);
        log.info("Current LocalDateTime: {}", localDateTime);
        log.info("Current ZonedDateTime: {}", zonedDateTime);
    }
}
